/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sbbs.springboot.sample4.demo;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 提供Demo服务类.
 *
 * @author Administrator
 *
 */
@Service
public class DemoService {

//    @Resource
    @Autowired
//    @injected
    private DemoRepository demoRepository;

    @Transactional
    public void save(Demo demo) {
        demoRepository.save(demo);
    }
    @Resource
    private DemoDao demoDao;

    public Demo getById(long id) {
        //demoRepository.findOne(id);//在demoRepository可以直接使用findOne进行获取.
        return demoDao.getById(id);
    }
}
